import request from "@/utils/request";
import type {
  AttrList,
  GetAttrListApiParams,
  SaveUpdateAttrApiParams,
} from "./model/attrModel";

enum Api {
  getAttrList = "/admin/product/attrInfoList",
  saveAttr = "/admin/product/saveAttrInfo",
  removeAttr = "/admin/product/deleteAttr",
}

// 获取属性列表
export const getAttrListApi = ({
  category1Id,
  category2Id,
  category3Id,
}: GetAttrListApiParams) => {
  return request.get<any, AttrList>(
    `${Api.getAttrList}/${category1Id}/${category2Id}/${category3Id}`
  );
};

// 添加属性
export const saveUpdateAttrApi = (data: SaveUpdateAttrApiParams) => {
  return request.post<any, null>(Api.saveAttr, data);
};

// 删除属性
export const removeAttrApi = (id: number) => {
  return request.delete<any, null>(`${Api.removeAttr}/${id}`);
};
